﻿//Write a program to calculate the Nth Catalan number by given N.

using System;
using System.Numerics;

class CalcCatalanNumbers
{
    static void Main()
    {
        Console.Write("Enter N = ");
        string nString = Console.ReadLine();
        int n = 1;
        if (int.TryParse(nString, out n) && n >= 0)
        {
            BigInteger result = 1;
            if (n > 1)
            {
                for (int i = 1; i <= n; i++)
                {
                    result = result * 2 * (2 * i - 1) / (i + 1);
                }
            }
            Console.WriteLine("C({0}) = {1}", n, result);
        }
        else
        {
            Console.WriteLine("Out of range () !");
        }
    }
}


